package com.kuzufang.modules.main.room;

import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.kuzufang.R;
import com.kuzufang.base.BaseFragment;
import com.kuzufang.view.UPullLoadMoreRecyclerView;
import com.wuxiaolong.pullloadmorerecyclerview.PullLoadMoreRecyclerView;

/**
 * Created by songyuanjin on 2017/8/28.
 */

public class FindRoomFragment extends BaseFragment {
    private UPullLoadMoreRecyclerView roommateRecyclerView;
    private RoomAdapter roomAdapter;


    public static BaseFragment getInstance() {
        return new FindRoomFragment();
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_find_room, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        roommateRecyclerView = (UPullLoadMoreRecyclerView) view.findViewById(R.id.roommate_list_view);
        roommateRecyclerView.setLinearLayout();
        roomAdapter = new RoomAdapter(getContext());
        roommateRecyclerView.setAdapter(roomAdapter);
        roomAdapter.setData();

        roommateRecyclerView.setOnPullLoadMoreListener(new PullLoadMoreRecyclerView.PullLoadMoreListener() {
            @Override
            public void onRefresh() {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        roommateRecyclerView.setPullLoadMoreCompleted();
                    }
                }, 2000);
            }

            @Override
            public void onLoadMore() {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        roommateRecyclerView.setPullLoadMoreCompleted();
                    }
                }, 2000);
            }
        });
    }

}
